#pragma once

#ifndef LEVEL_H
#define LEVEL_H

#include <string>
#include "LevelSquare.h"
#include "Entity.h"
#include "Collision.h"

class Level
{
private:
	int width;
	int height;
	int ID;
	D3DVIEWPORT9 viewport;
	D3DXVECTOR3 initOffset;
	D3DXVECTOR3 offset;
	D3DXVECTOR3 startPoint;
	D3DXVECTOR3 endPoint;
	TileSet* tileset;
	LevelSquare** squares;
public:
	Level(int width, int height, D3DVIEWPORT9 viewport, TileSet* tileset, 
		D3DXVECTOR3 startPoint, D3DXVECTOR3 endPoint, D3DXVECTOR3 offset);
	~Level();
	LevelSquare getSquare(int x, int y) { return squares[x][y]; }
	void clearSquare(int x, int y) { squares[x][y].setVisible(false); }
	void setSquare(int x, int y, LevelSquare square);
	void draw(ID3DXSprite* sprite);
	D3DXVECTOR3 checkCollision(Entity* entity, BoundingBox& bounds, D3DXVECTOR3 movement);
	static Level* createLevel(TileSet* tileSet, std::string path,
		D3DVIEWPORT9 viewport, D3DXVECTOR3 startPoint, D3DXVECTOR3 endPoint, D3DXVECTOR3 offset);
	// Getters and setters.
	int getWidth() { return width; }
	void setWidth(int newWidth) { width = newWidth; }
	int getHeight() { return height; }
	void setHeight(int newHeight) { height = newHeight; }
	int getID() const { return ID; }
	void setID(int newID) { ID = newID; }
	D3DVIEWPORT9 getViewport() { return viewport; }
	void setViewport(D3DVIEWPORT9 newViewport) { viewport = newViewport; }
	D3DXVECTOR3 getOffset() { return offset; }
	D3DXVECTOR3 getInitOffset() { return initOffset; }
	D3DXVECTOR3 getStartPoint() { return startPoint; }
	D3DXVECTOR3 getEndPoint() { return endPoint; }
	void setOffset(D3DXVECTOR3 newOffset) { offset = newOffset; }
	TileSet* getTileSet() { return tileset; }
	void setTileSet(TileSet* newTileSet) { tileset = newTileSet; }
};

#endif